<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %><!-- 数据库操作需要 -->        
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>个人信息</title>
    <link rel="stylesheet" href="UC_style.css">
    <style>
        

        #header2 {
            height: 40px;
            background: white;
        }
        .had {
            text-align: center;
            height: 500px;
            width: 60%;
            margin: 0px auto;
        }

        .input1 {
            border: none;
            height: 90%;
            width: 100%;
            font-size: 16px;
            outline: none;
        }

        .input2 {
            color: black;
            background-color: RGB(239,239,239);
            font-size: 20px;
            height: 40px;
            width: 100px;
            margin-left: 450px;
            margin-right: 30px;
        }

            .input2:hover {
                background-color: #808080;
            }

        .text {
            border: none;
            height: 50px;
            width: 100%;
            font-size: 16px;
        }

        select {
            border: 0px;
            height: 90%;
            width: 90%;
            outline: none;
        }

        .textarea1 {
            border: 0px;
            width: 100%;
            resize: none;
            height:90%;
            font-size: 16px;
        }
        .textarea2 {
            border: 3px solid #d2d2d2;
            width: 100%;
            resize: none;
            height: 100px;
            font-size: 16px;
        }
        .button1 {
            color: black;
            background-color: RGB(239,239,239);
            font-size: 20px;
            height: 40px;
            width: 100px;
            margin-left: 450px;
            margin-right: 30px;
        }

        h3 {
            text-align: center;
        }

        .black_overlay {
            display: none; /* 此元素不会被显示*/
            position: absolute;
            top: 0%;
            left: 0%;
            width: 100%;
            height: 100%;
            background-color: black;
            z-index: 1001; /* z-index 属性设置元素的堆叠顺序。拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面。*/
            opacity: 0.8;
            opacity: .80; /* opacity 属性设置元素的不透明级别。*/
            filter: alpha(opacity=88);
            /* 所有浏览器都支持 opacity 属性。   注释：IE8 以及更早的版本支持替代的 filter 属性。例如：filter:Alpha(opacity=50)。*/
        }

        .white_content {
            display: none;
            position: absolute;
            top: 25%;
            left: 25%;
            width: 55%;
            height: 55%;
            padding: 20px;
            border: 10px solid #00ffff;
            background-color: white;
            z-index: 1002;
            overflow: auto;
        }
        
        .table1{
			width:100%;
			border:0;
		}
.dv1{
	width:400px;
	float:left;
	height:22px;
	
}
.dv2{
	width:120px;
	float:left;
	height:22px;
}
.dv3{
	width:280px;
	float:left;
	height:22px;
}
.div_main1{	
	background:white;
	
	width:80%;
	/*border-style:ridge;
	border-color:RGBA(255,255,255,0.3);*/
	margin-left:10%;
	margin-right:10%;
}
td{
	border:none;
	padding:15px 10px;
}
.button_Select{
		background-color:RGB(23,28,33);
    	border-width: 1px;
    	color: white;
    	padding: 5px 10px;
    	width: 100px;
   	 	text-align: center;
    	font-size: 16px;
    	border-radius: 12px;
	}
.button_Select:hover {
    background-color:RGB(38,169,226);
}
    </style>
</head>

<body>
<%	try {
			Class.forName("org.h2.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			return;
		}
	String url="jdbc:h2:d:/CompanyCar/temp/mydbtest";
		Connection conn=null;
		
		//数据库连接与查询过程中可能会引发sql异常
		try {
			//获取数据库连接(url,username,password)			
			conn = DriverManager.getConnection(url,"sa","");
			//准备执行数据库查询
			String EmpID=request.getParameter("EmpID");
			System.out.println(EmpID);
			request.setAttribute("EmpID",EmpID);
			System.out.println(EmpID);
			String sql="";
			sql="select * from Employee where EmpID='"+EmpID+"' ";
			Statement stmt=conn.createStatement();
			
			//pstmt.setString(1, account);
			//执行数据库查询，获取结果集
			ResultSet rs=stmt.executeQuery(sql);
			if (rs.next()){				
				String Name=rs.getString("Name");
				request.setAttribute("Name",Name);
				String Gender=rs.getString("Gender");
				String Age=rs.getString("Age");
				System.out.println(Age);
				request.setAttribute("Age",Age);
				String IDNumber=rs.getString("IDNumber");
				request.setAttribute("IDNumber",IDNumber);
				String Phone=rs.getString("Phone");
				request.setAttribute("Phone",Phone);
				String Address=rs.getString("Address");
				request.setAttribute("Address",Address);
				String Department=rs.getString("Department");
				request.setAttribute("Department",Department);
				String Rank=rs.getString("Rank");
				request.setAttribute("Rank",Rank);
				String Position=rs.getString("Position");
				request.setAttribute("Position",Position);
				String Hometown=rs.getString("Hometown");
				request.setAttribute("Hometown",Hometown);
				String Education=rs.getString("Education");
				request.setAttribute("Education",Education);
				String YearsOfWorking=rs.getString("YearsOfWorking");
				request.setAttribute("YearsOfWorking",YearsOfWorking);
				String HireDate=rs.getString("HireDate");
				request.setAttribute("HireDate",HireDate);
				String MaritalStatus=rs.getString("MaritalStatus");
				request.setAttribute("MaritalStatus",MaritalStatus);
				String Birthplace=rs.getString("Birthplace");
				request.setAttribute("Birthplace",Birthplace);
				String Birthday=rs.getString("Birthday");
				request.setAttribute("Birthday",Birthday);
				String EthnicGroup=rs.getString("EthnicGroup");	
				request.setAttribute("EthnicGroup",EthnicGroup);
				
					//获取第1个字段
			}				
			//关闭表达式对象
			stmt.close();			
			//关闭数据库			
			conn.close();			
					
			%>
    <div class="main" style="background-color:white ">
        <div id="header2">
            <img src="img/frist.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
            乘客用车管理 > 个人信息
        </div>
        <br />
        <h3>个人信息</h3>
        <br />
            <div class="div_main1">
        <form action="X-jdbc-UseCar_PersonalInformation.jsp" method="post">
			<table class="table1">
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">姓名：</div>
							<div class="dv3"><input name="Name" id="name" type="text" class="text1" value=<%=request.getAttribute("Name") %> readonly></div>
						</div>
				
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">性别：</div>
							<div class="dv3"><input name="Gender" type="text" class="text1" value=<%=request.getAttribute("Gender") %> readonly></div>
						</div>
					</td>				
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">身份证号：</div>
							<div class="dv3"><input name="IDNumber" type="text" class="text1" value=<%=request.getAttribute("IDNumber") %> readonly></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">学历：</div>
							<div class="dv3"><input name="Education" type="text" class="text1" value=<%=request.getAttribute("Education") %> readonly></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">出生日期：</div>
							<div class="dv3"><input name="Birthday" type="text" class="text1" value=<%=request.getAttribute("Birthday") %> readonly></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">年龄：</div>
							<div class="dv3"><input name="Age" type="text" class="text1" value=<%=request.getAttribute("Age") %> readonly></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">籍贯：</div>
							<div class="dv3"><input name="Birthplace" type="text" class="text1" value=<%=request.getAttribute("Birthplace") %> readonly></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">民族：</div>
							<div class="dv3"><input name="EthnicGroup" type="text" class="text1" value=<%=request.getAttribute("EthnicGroup") %> readonly></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">户籍所在地：</div>
							<div class="dv3"><input name="Hometown" type="text" class="text1" value=<%=request.getAttribute("Hometown") %> readonly></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">现住地址：</div>
							<div class="dv3"><input name="Address" type="text" class="text1" value=<%=request.getAttribute("Address") %> readonly></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">婚姻状况：</div>
							<div class="dv3"><input name="MaritalStatus" type="text" class="text1" value=<%=request.getAttribute("MaritalStatus") %> readonly></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">联系电话：</div>
							<div class="dv3"><input name="Phone" type="text" class="text1" value=<%=request.getAttribute("Phone") %> readonly></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">工号：</div>
							<div class="dv3"><input name="EmpID" type="text" class="text1" value=<%=request.getAttribute("EmpID") %> readonly></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">部门：</div>
							<div class="dv3"><input name="Department" type="text" class="text1" value=<%=request.getAttribute("Department") %> readonly></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">岗位：</div>
							<div class="dv3"><input name="Position" type="text" class="text1" value=<%=request.getAttribute("Position") %> readonly></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">职级：</div>
							<div class="dv3"><input name="Rank" type="text" class="text1" value=<%=request.getAttribute("Rank") %> readonly></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">入职时间：</div>
							<div class="dv3"><input name="HireDate" type="text" class="text1" value=<%=request.getAttribute("HireDate") %> readonly></div>
						</div>
						
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">在职年限：</div>
							<div class="dv3"><input name="YearsOfWorking" type="text" class="text1" value=<%=request.getAttribute("YearsOfWorking") %> readonly></div>
						</div>
						
					</td>

				</tr>	
				<tr>
					<td>
					    
					    <input id="bc" type="submit" class="button_Select" style="float:left;margin-left:100px;display:none;" onclick="fun()" value="保存"/>
					    <input type="hidden" name="EmpID" value=EmpID>				
						<input type="button" id="bj" class="button_Select" style="float:left;display:block;;display:inline-block;" onclick="next()" value="编辑">
						<input type="button" class="button_Select" style="float:right;display:inline-block;" onclick="javascript:history.back(-1);" value="返回">
				</td>
				</tr>			
			</table>
			</form>
			</div>
		</div>
<%
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			//防止数据库未正常关闭
			try{
				if (conn!=null && (!conn.isClosed())){
					conn.close();
				}
			}catch(SQLException e){
				e.printStackTrace();
			}
		}
%>
            <br />
            <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
            <script type="text/javascript">
            var inputs = document.querySelectorAll('input[readonly]');
			function next(){
            	document.getElementById('bj').style.display ='none';
            	document.getElementById('bc').style.display ='block';
            	$('input[readonly]').removeAttr('readonly');
            	
            }

           
            function fun(){
            	document.getElementById('bc').style.display ='none';
            	document.getElementById('bj').style.display ='block';
            	
            }
            
            </script>
</body>

</html>
